<?php

$destination_dir = "img/";
if(
  isset($_FILES["Filedata"]) &&
  is_array($_FILES["Filedata"]) &&
  isset(
      $_FILES["Filedata"]["tmp_name"],
      $_FILES["Filedata"]["name"],
      $_FILES["Filedata"]["size"],
      $_FILES["Filedata"]["error"]
  ) &&
  intVal($_FILES["Filedata"]["error"]) === 0
) {
  if(move_uploaded_file($_FILES["Filedata"]["tmp_name"], $destination_dir.$_FILES["Filedata"]["name"])) {
      $result = "
          Date: ".date("Y-m-d H:i:s")."
          File: {$_FILES["Filedata"]["name"]}
          Size: {$_FILES["Filedata"]["size"]}
          Successfull uploaded.
      ";
  }
  else {
      $result = "
          Date: ".date("Y-m-d H:i:s")."
          File: {$_FILES["Filedata"]["name"]}
          Size: {$_FILES["Filedata"]["size"]}
          Error: {$_FILES["Filedata"]["error"]}
          Unable to move file.
      ";
  }
  if(@$fp = fopen($destination_dir."upload.txt", "w")) {
      fwrite($fp, $result);
      fclose($fp);
  }
}
?>